package com.itheima;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;

import javax.servlet.MultipartConfigElement;

/**
 * Hello world!
 *
 */
@Configuration
@SpringBootApplication
@MapperScan("com.itheima.mapper")
public class App 
{
    public static void main( String[] args )
    {

        SpringApplication.run(App.class, args);
    }
    @Bean
    public MultipartConfigElement getMultipartConfigElement() {
        //1.创建一个配置的工厂类对象
        MultipartConfigFactory factory = new MultipartConfigFactory();

        //2.设置需要创建的对象的相关信息
        factory.setMaxFileSize(DataSize.of(10, DataUnit.MEGABYTES));
        factory.setMaxRequestSize(DataSize.of(15, DataUnit.MEGABYTES));

        //3.通过工厂类创建MultipartConfigElement对象
        return factory.createMultipartConfig();
    }
}
